import { type App } from "vue"
// https://vxetable.cn/#/table/start/install
import VXETable from "vxe-table"
// https://github.com/x-extends/vxe-table-plugin-element
import VXETablePluginElement from "vxe-table-plugin-element"

VXETable.use(VXETablePluginElement)

// 全局默认参数
VXETable.setup({
  // 全局尺寸
  size: "medium",
  // 版本号，对于某些带数据缓存的功能有用到，上升版本号可以用于重置数据
  version: 0,
  // 全局 loading 提示内容，如果为 null 则不显示文本
  loadingText: null,
  table: {
    showHeader: true,
    showOverflow: "tooltip",
    showHeaderOverflow: "tooltip",
    autoResize: true,
    stripe: true,
    border: true,
    round: true,
    emptyText: "暂无数据",
    rowConfig: {
      isHover: true,
      isCurrent: true
    },
    columnConfig: {
      resizable: true
    },
    align: "center",
    headerAlign: "center",
  },
  pager: {
    size: "medium",
    // 配套的样式
    perfect: false,
    pageSize: 10,
    pagerCount: 7,
    pageSizes: [10, 20, 50, 100],
    layouts: ["Total", "PrevJump", "PrevPage", "Number", "NextPage", "NextJump", "Sizes", "FullJump"]
  },
  modal: {
    minWidth: 500,
    minHeight: 400,
    mask: true,
    duration: 3000,
    marginSize: 20,
    showFooter: true,
    showTitleOverflow: true,
    transfer: true,
    draggable: true,
    escClosable: false,
    destroyOnClose: true
  }
})

export function loadVxeTable(app: App) {
  // Vxe Table 组件完整引入
  app.use(VXETable)
}
